package com.utils;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;


public class ImageUtil {
public static Map<String, BufferedImage> createImage() {
	Map<String, BufferedImage> map = new HashMap<String, BufferedImage>();
	int width = 80;
	int height = 30;
	BufferedImage image = new BufferedImage(width, height,
			BufferedImage.TYPE_INT_RGB);
	Graphics g = image.getGraphics();
	Random r = new Random();
	String num =Integer.toString(r.nextInt(9999-1000)+1000);
	g.setColor(new Color(255,255,255));
	g.fillRect(0, 0, width, height);
	g.setColor(new Color(0,0,0));
	g.setFont(new Font("宋体",Font.BOLD,15));
	int left = 8;
	for (char c : num.toCharArray()) {
		g.setColor(new Color(r.nextInt(255),r.nextInt(255),r.nextInt(255)));
		g.drawString(Character.toString(c), left, 20);
		left+=10;
		
	}
	for (int i = 0; i < 4; i++) {
		g.setColor(new Color(0,0,0));
		g.drawLine(r.nextInt(60), r.nextInt(20), r.nextInt(60), r.nextInt(20));
	}
	map.put(num, image);
	return map;

}
}
